package com.gitee.wsl.ext.collection


/**
 * Consume this iterator by taking the first [count] elements
 */
fun <T> Iterator<T>.take(count: Int): List<T> = List(count) { next() }

fun <T> Iterable<T>.take(n: Int, default: T): List<T> {
    val result = take(n)
    return result + List(n - result.size) { default }
}